package com.wicket.okrcomponent.biz.service.nb;

import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrcomponent.biz.service.dto.req.ImplementNumericalAccuracyProcessingReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ImplementNumericalAccuracyProcessingRespDto;

import java.math.BigDecimal;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
public class NbBusinessInterfaceMode {
/**
      * code:numericalAccuracyProcessing
      * name:M2执行数值精度处理（特殊方法）
      * desc:undefined
      * gen by moon at 4/26/2024, 2:22:32 PM
      * 
      **/
     @Trace(operationName = "M2执行数值精度处理（特殊方法）")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementNumericalAccuracyProcessingRespDto implementNumericalAccuracyProcessing(ImplementNumericalAccuracyProcessingReqDto reqDto) {
         ImplementNumericalAccuracyProcessingRespDto retData = new ImplementNumericalAccuracyProcessingRespDto();
         int mode = -1;
         if(reqDto.getDecimalDigitsLastRules()!=null){
             mode = BigDecimal.ROUND_HALF_UP;
             if(reqDto.getDecimalDigitsLastRules().equals("MALING")){
                 mode = BigDecimal.ROUND_DOWN;
             }
         }
         BigDecimal calcResult = new BigDecimal(reqDto.getComFloatField().toString());
         if(mode!=-1){
             calcResult = calcResult.setScale(reqDto.getDecimalPointRules().intValue(),mode);
         }
         retData.setComFloatField(calcResult.doubleValue());
        return retData;
      }
  //手工接入方法
}
